package com.multi_allergy;

import java.util.*;
public class AirplaneMenu {

	private int cost;
	
	
	public int getCost() {
		return cost;
	}

	public void setCost(int cost) {
		this.cost = cost;
	}

	public AirplaneMenu(String name,int cost) {
		super();
		this.name = name;
		this.cost=cost;
		this.ingredients=new Vector();
	}

	private String name;
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	private Collection <String> ingredients;

	public Collection<String> getIngredients() {
		return ingredients;
	}

	public void setIngredient(String ingredient) {
		this.ingredients.add(ingredient.toLowerCase());
	}

	public boolean contains(String ingredient)
	{
		Iterator<String> iter=ingredients.iterator();
		while(iter.hasNext())
			if(ingredient.equalsIgnoreCase(iter.next()))
				return true;
		
		
		return false;
	}
	
	public boolean contains(Collection<String> allergies)
	{
		Iterator<String> allergyIter=allergies.iterator();
		while (allergyIter.hasNext())
		{
		String ingredient = allergyIter.next();
		Iterator<String> iter=ingredients.iterator();
		while(iter.hasNext())
			if(ingredient.equalsIgnoreCase(iter.next()))
				return true;
		
		}
		return false;
	}	
	
	public String toString()
	{
		String output="Menu\n";
	
		Iterator<String> iter=ingredients.iterator();
		while(iter.hasNext())
			output+=iter.next()+"\n";
		
		return output;
		
	}
}
